package com.sloera.net;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class BIOServer {

    private static ExecutorService executorService = Executors.newCachedThreadPool();

    public static void startServer(int port) throws IOException {


        ServerSocket serverSocket = new ServerSocket(port);

        while (true) {
            Socket socket = serverSocket.accept(); //阻塞的等待客户端连接
            executorService.submit(new RPCThreadProcessor(socket)); // 交给线程池
        }


    }
}
